import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/r.dart';
import 'package:flutter_app/values/MyColors.dart';
import 'package:flutter_app/widget/custom_app_bar.dart';
import 'package:flutter_screenutil/src/size_extension.dart';
import 'package:get/get.dart';

import 'photo_gallery_logic.dart';

/**
 * @Description: 相册 可视化采集资料
 * @Author: 下雨了
 * @CreateDate: 2022-7-5 16:55:13
 * @UpdateUser: 更新者
 * @UpdateDate:  2022-7-5 16:55:16
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
///
class PhotoGalleryPage extends StatefulWidget {
  final String title;

  const PhotoGalleryPage({Key? key, required this.title}) : super(key: key);

  @override
  _PhotoGalleryPageState createState() => _PhotoGalleryPageState();
}

class _PhotoGalleryPageState extends State<PhotoGalleryPage> {
  final logic = Get.put(PhotoGalleryLogic());
  final state = Get.find<PhotoGalleryLogic>().state;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<PhotoGalleryLogic>(builder: (logic) {
      return Scaffold(
        backgroundColor: MyColors.FFF1F1F1,
        appBar: MyAppBar(context, title: "可视化采集资料"),
        body: Column(
          children: [
            Container(
              color: Colors.white,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  BrnTabBar(
                    mode: BrnTabBarBadgeMode.average,
                    tabWidth: 58.r,
                    tabs: logic.badgeTab,
                    controller: logic.tabController,
                    indicatorWeight: 0.r,
                    indicatorColor: Colors.transparent,
                    backgroundcolor: Colors.white,
                    padding: EdgeInsets.only(left: 2.5.r,),
                    labelStyle: TextStyle(
                        color: MyColors.FF2763B9,
                        fontSize: 16.sp,
                        fontWeight: FontWeight.w500),
                    unselectedLabelStyle: TextStyle(
                        color: MyColors.FF010101,
                        fontSize: 16.sp,
                        fontWeight: FontWeight.w500),
                  ),
                  SizedBox(
                    height: 50.r,
                    child: TextButton(
                      onPressed: () {
                        logic.edit();
                      },
                      child: Text(state.edit, style: TextStyle(color: MyColors.FF333333, fontSize: 14.sp),),
                    ),
                  )
                ],
              ),
            ),
            Expanded(
              child: Container(
                margin: EdgeInsets.only(top: 10.r),
                padding: EdgeInsets.only(top: 11.r, left: 16.r, right: 16.r),
                color: Colors.white,
                child: TabBarView(
                  children: logic.widgets,
                  controller: logic.tabController,
                ),
              ),
            ),
          ],
        ),
        bottomNavigationBar: Visibility(
          visible: state.isEdit.value,
          child: Container(
            decoration: BoxDecoration(
                boxShadow: [BoxShadow(
                  color: Color(0x1a000000),
                  blurRadius: 6.67.r,
                  spreadRadius: 0.05.r,
                )],
                shape: BoxShape.rectangle,
                color: Colors.white
            ),
            padding: EdgeInsets.fromLTRB(16.r, 5.r, 16.r, 5.r),
            child: SafeArea(
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: [
                  InkWell(
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Image.asset(R.assetsImgIcon75, height: 20.r,),
                        SizedBox(height: 4.r,),
                        Text("全选", style: TextStyle(color: MyColors.FF333333, fontSize: 12.sp),)
                      ],
                    ),
                    onTap: () {
                      logic.all();
                    },
                  ),
                  InkWell(
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Image.asset(R.assetsImgIcon77, height: 20.r,),
                        SizedBox(height: 4.r,),
                        Text("删除", style: TextStyle(color: MyColors.FF333333, fontSize: 12.sp),)
                      ],
                    ),
                    onTap: () {
                      logic.delete();
                    },
                  ),
                ],
              ),
            ),
          ),
        ),
      );
    });
  }

  @override
  void dispose() {
    Get.delete<PhotoGalleryLogic>();
    super.dispose();
  }
}
